<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>申请资源</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
  </head>
  
  <body>
    <center>
    <a style="float: left" href="<%=basePath%>signlist">查看申请列表</a><br>
    <a style="float: left" href="<%=basePath%>resourcelist">查看资源列表</a>
    申请资源. <br>
    
	    <form action="<%=basePath%>addSign" method="post" id="signform">
	    	<table>
	    		<tr>
	    			<td>资源名称：</td>
	    			<td>
	    				<select name="resourcesEntity" id="resourcesEntity" width="100px;">
	    					<c:forEach items="${list }" var="obj">
	    						<option value="${obj.id }" data-holder="${obj.holder }">${obj.name }</option>
	    					</c:forEach>
	    				</select>
	    			<td>
	    		</tr>
	    		<tr>
	    			<td>持有人：</td>
	    			<td> <span id="holderspan">${list[0].holder }</span></td>
	    		</tr>
	    		<tr>
	    			<td>申请人：</td>
	    			<td><input name="signName" id="signName" type="text" width="100px;"></td>
	    		</tr>
	    		
	    		<tr>
	    			<td>理由：</td>
	    			<td><input name="signReason" id="signReason" type="text" width="100px;"></td>
	    		</tr>
	    		<tr>
	    			<td>提交：</td>
	    			<td><input id="signbutton" type="button" width="100px;" value="提交"></td>
	    		</tr>
	    	</table>
	    	
	    	
	    </form>
    </center>
  </body>
  <script type="text/javascript">
  	$("#resourcesEntity").bind("change",function(){
  		var holderspan=$("#resourcesEntity").find("option:checked").data("holder");
  		$("#holderspan").html(holderspan);
  	});
  	
  	$("#signbutton").bind("click",function(){
  		if($("#signName").val()==""){
			alert("请输入姓名!");
			return;
		}
  		if($("#signReason").val()==""){
			alert("不填点什么?");
			return;
		}
		$(this).unbind("click");
  	  	$.ajax({
  		    type: "POST",
  		    url: "/addSign",
  		    dataType: 'text',
  		    data:$('#signform').serialize(),
  		    success: function(data){
  		    	alert(data);
				//location.reload();
				location.href="/sign";
				
				
  		    }
  		});	
  	});
  	
  	
  </script>
</html>
